![]() |
ALMaSS
1.0
The Animal, Landscape and Man Simulation System
|
The class to handle all predator population related matters. More...
#include <Hunters_all.h>
Public Member Functions | |
Hunter_Population_Manager (Landscape *p_L) | |
Hunter population manager constructor. More... | |
virtual | ~Hunter_Population_Manager (void) |
Hunter population manager destructor. More... | |
void | Init (void) |
Create the initial hunter population and initializes any output options. More... | |
void | DistributeHunters (void) |
Distributes hunters to hunting locations (farms). More... | |
void | DistributeHuntersByRules (vector< HunterInfo > *a_hunterlist, int a_no_hunters, int a_ruleset) |
Implements the rule sets to distributes hunters to hunting locations (farms). More... | |
void | RuleSet10Based (int a_no_hunters, vector< int > *a_farmsizes, vector< HunterInfo > *a_hunterlist, vector< APoint > *a_roostlocs, int a_ruleset) |
Used to implement rule sets based on rule set 10. More... | |
void | SaveDistributedHunters (vector< HunterInfo > *a_hunterlist, int a_no_hunters) |
Saves the results of the hunter distribution to an output file. More... | |
void | SaveFarmHunters (vector< HunterInfo > *a_hunterlist, int a_no_hunters) |
Saves the results of the hunter distribution to an output file by farm. More... | |
void | CreateObjects (int ob_type, TAnimal *, struct_Hunter *data, int number) |
Creates hunter objects and assigns them to the population manager lists. More... | |
void | RecordHuntingSuccess (int poly, int birds, int a_hunter) |
Hunting bag output. More... | |
APoint | GetHunterHome (int a_index, int a_list) |
Returns the hunter home location. More... | |
APoint | GetHunterHuntLoc (int a_index, int a_list, unsigned a_ref) |
Returns the hunter hunting location location. More... | |
unsigned | GetNoHuntLocs () |
Calculates the number of hunting locations based on a distribution. More... | |
bool | CheckDensity (int a_ref, vector< int > *a_illegalfarms, vector< FarmOccupcancyData > *a_FarmOccupancy) |
helper method to reduce code size in hunter rules - checks density rules More... | |
bool | AddHunterHunting (int a_polyref, Hunter *a_hunter) |
Adds a hunter hunting, returns true if that hunter is the leader otherwise false. More... | |
void | HunterLeaderMessage (TypeOfHunterLeaderMessage a_signal, int a_polyref) |
A message system to rely messages from the leader hunter to others in his team. More... | |
bool | IsPolyrefOnActiveList (int a_polyref) |
Debugging check method. More... | |
void | SetHuntingSeason () |
This returns the number of geese which are legal quarry on the polygon the day before. More... | |
int | GetHuntingSeasonStart () |
Get the start of the overall hunting season. More... | |
int | GetHuntingSeasonEnd () |
Get the end of the overall hunting season. More... | |
![]() | |
Population_Manager (Landscape *L) | |
virtual | ~Population_Manager (void) |
void | SetNoProbes (int a_pn) |
unsigned | GetLiveArraySize (int a_listindex) |
Gets the number of 'live' objects for a list index in the TheArray. More... | |
void | IncLiveArraySize (int a_listindex) |
Increments the number of 'live' objects for a list index in the TheArray. More... | |
virtual void | Catastrophe (int) |
unsigned int | FarmAnimalCensus (unsigned int a_farm, unsigned int a_typeofanimal) |
char * | SpeciesSpecificReporting (int a_species, int a_time) |
char * | ProbeReport (int a_time) |
char * | ProbeReportTimed (int a_time) |
void | ImpactProbeReport (int a_Time) |
bool | BeginningOfMonth () |
void | LOG (const char *fname) |
int | SupplyStepSize () |
int | SupplySimW () |
int | SupplySimH () |
virtual void | Run (int NoTSteps) |
virtual float | Probe (int ListIndex, probe_data *p_TheProbe) |
virtual void | ImpactedProbe () |
int | SupplyListNameLength () |
TAnimal * | SupplyAnimalPtr (int a_index, int a_animal) |
Returns the pointer indexed by a_index and a_animal. Note NO RANGE CHECK. More... | |
unsigned | SupplyListIndexSize () |
unsigned | SupplyListSize (unsigned listindex) |
bool | CheckXY (int l, int i) |
Debug method to test for out of bounds coordinates. More... | |
const char * | SupplyListName (int i) |
bool | IsLast (unsigned listindex) |
int | SupplyState (unsigned listindex, unsigned j) |
virtual void | SupplyLocXY (unsigned listindex, unsigned j, int &x, int &y) |
const char * | SupplyStateNames (int i) |
unsigned | SupplyStateNamesLength () |
virtual void | DisplayLocations () |
int | ProbeFileInput (char *p_Filename, int p_ProbeNo) |
TAnimal * | FindClosest (int x, int y, unsigned Type) |
bool | OpenTheRipleysOutputProbe (string a_NWordFilename) |
void | OpenTheAOROutputProbe (string a_AORFilename) |
bool | OpenTheMonthlyRipleysOutputProbe () |
bool | OpenTheReallyBigProbe () |
virtual void | TheAOROutputProbe () |
virtual void | TheRipleysOutputProbe (FILE *a_prb) |
virtual void | TheReallyBigOutputProbe () |
void | CloseTheMonthlyRipleysOutputProbe () |
virtual void | CloseTheRipleysOutputProbe () |
virtual void | CloseTheReallyBigOutputProbe () |
TTypesOfPopulation | GetPopulationType () |
int | GetSeasonNumber () |
Get the season number. More... | |
void | LamdaDeath (int x, int y) |
void | LamdaBirth (int x, int y) |
void | LamdaBirth (int x, int y, int z) |
void | LamdaClear () |
void | LamdaDumpOutput () |
virtual int | SupplyPegPosx (int) |
virtual int | SupplyPegPosy (int) |
virtual int | SupplyCovPosx (int) |
virtual int | SupplyCovPosy (int) |
virtual bool | OpenTheFledgelingProbe () |
virtual bool | OpenTheBreedingPairsProbe () |
virtual bool | OpenTheBreedingSuccessProbe () |
virtual void | BreedingPairsOutput (int) |
virtual int | TheBreedingFemalesProbe (int) |
virtual int | TheFledgelingProbe () |
virtual void | BreedingSuccessProbeOutput (double, int, int, int, int, int, int, int) |
virtual int | TheBreedingSuccessProbe (int &, int &, int &, int &, int &, int &) |
virtual void | FledgelingProbeOutput (int, int) |
virtual void | TheGeneticProbe (unsigned, int, unsigned &) |
virtual void | GeneticsResultsOutput (FILE *, unsigned) |
Public Attributes | |
vector< HunterList * > | m_ActiveHuntingLocationsHunters |
Lists of hunters at all active hunting locations (updated daily) More... | |
vector< int > | m_ActiveHuntingLocationsPolyrefs |
Lists of polygon reference numbers for all active hunting locations (updated daily) More... | |
![]() | |
int | IndexArrayX [5][10000] |
probe_data * | TheProbe [100] |
int | SimH |
int | SimW |
unsigned | SimHH |
unsigned | SimWH |
char | m_SimulationName [255] |
bool | ProbesSet |
Landscape * | m_TheLandscape |
Protected Member Functions | |
virtual bool | StepFinished () |
Overrides the population manager StepFinished - there is no chance that hunters do not finish a step behaviour. More... | |
virtual void | DoFirst () |
Does general daily tasks e.g. reset time of day, reset bag lists if start of year etc.. More... | |
virtual void | DoBefore () |
Available for hunter management - not used currently. More... | |
virtual void | DoAfter () |
Available for hunter management - not used currently. More... | |
virtual void | DoLast () |
Available for hunter management - not used currently. More... | |
![]() | |
virtual void | DoAlmostLast () |
void | EmptyTheArray () |
Removes all objects from the TheArray by deleting them and clearing TheArray. More... | |
void | SortX (unsigned Type) |
void | SortXIndex (unsigned Type) |
void | SortY (unsigned Type) |
void | SortState (unsigned Type) |
void | SortStateR (unsigned Type) |
unsigned | PartitionLiveDead (unsigned Type) |
void | Shuffle_or_Sort (unsigned Type) |
void | Shuffle (unsigned Type) |
virtual void | Catastrophe () |
The class to handle all predator population related matters.
Hunter_Population_Manager::Hunter_Population_Manager | ( | Landscape * | p_L | ) |
Hunter population manager constructor.
There are two possibilities here - we can be in simulation mode or distribution mode. Simulation mode calls Init and runs hunters as normal whereas distribution mode will attempt to distribute hunters to hunting locations based on model rules. This is also needed for the first time simulations are run to distribute the hunters and produce input for Hunter_Initiation.txt
References Population_Manager::BeforeStepActions, cfg_Hunters_Distribute, DistributeHunters(), Init(), m_HuntingSeasonEnd, m_HuntingSeasonStart, Population_Manager::m_ListNameLength, Population_Manager::m_ListNames, SetHuntingSeason(), Population_Manager::TheArray, and CfgBool::value().
|
virtual |
Hunter population manager destructor.
References cfg_Hunters_RecordBag, m_HuntingBagRecord, and CfgBool::value().
bool Hunter_Population_Manager::AddHunterHunting | ( | int | a_polyref, |
Hunter * | a_hunter | ||
) |
Adds a hunter hunting, returns true if that hunter is the leader otherwise false.
The field that a hunter is hunting is referenced by a_polyref. First we need to check whether this location already exists. NB this list is emptied every day, so only contains locations where hunters have been or are allocated today.
If the location is found, then the hunter is not a leader and we need to tell them that (returns false)
If the polyref does not already exist the location was not found, it must be new, so we need to add it to the list and tell the hunter he is a leader
References m_ActiveHuntingLocationsHunters, and m_ActiveHuntingLocationsPolyrefs.
Referenced by GooseHunter::st_OutHunting().
bool Hunter_Population_Manager::CheckDensity | ( | int | a_ref, |
vector< int > * | a_illegalfarms, | ||
vector< FarmOccupcancyData > * | a_FarmOccupancy | ||
) |
helper method to reduce code size in hunter rules - checks density rules
[in] | a_ref | The farm reference number |
[in] | a_illegalfarms | The list of farms with densities exceeding the limit set for this run |
[in] | a_FarmOccupancy | The list of farms that are occupied and the number of hunters allocated to them |
Area is in m2, so divide by 10000. Hunter density in hunters/ha
Loop through all the farms that are already occupied and figure out if we have this one already
References FarmManager::AddToIllegalList(), cfg_goose_MinForageOpenness, cfg_Hunters_MaxDensity, FarmManager::GetFarmAreaOpenFields(), FarmOccupcancyData::m_FarmRef, FarmOccupcancyData::m_no_hunters, Population_Manager::m_TheLandscape, Landscape::SupplyFarmManagerPtr(), and CfgFloat::value().
Referenced by DistributeHuntersByRules(), and RuleSet10Based().
void Hunter_Population_Manager::CreateObjects | ( | int | ob_type, |
TAnimal * | , | ||
struct_Hunter * | data, | ||
int | number | ||
) |
Creates hunter objects and assigns them to the population manager lists.
References g_PopulationManagerList, PopulationManagerList::GetPopulation(), Population_Manager::m_TheLandscape, Population_Manager::TheArray, toh_GooseHunter, TOP_Goose, and Landscape::Warn().
Referenced by Init().
void Hunter_Population_Manager::DistributeHunters | ( | void | ) |
Distributes hunters to hunting locations (farms).
Reads in the hunter home data which consists of a hunter reference and home x,y coordinates only. Hunter type is by default 0 i.e. goose hunter (to be changed when we have more hunter base types)
We now need to add the number of hunting locations to each hunter. This is done by the method GetNoHuntLocs() which returns the number of locations. We use this to resize the storage for the number of locations.
References cfg_Hunters_Distribute_Ruleset, DistributeHuntersByRules(), g_msg, GetNoHuntLocs(), Population_Manager::m_TheLandscape, SaveDistributedHunters(), SaveFarmHunters(), CfgInt::value(), MapErrorMsg::Warn(), and Landscape::Warn().
Referenced by Hunter_Population_Manager().
void Hunter_Population_Manager::DistributeHuntersByRules | ( | vector< HunterInfo > * | a_hunterlist, |
int | a_no_hunters, | ||
int | a_ruleset | ||
) |
Implements the rule sets to distributes hunters to hunting locations (farms).
To distribute the hunters to farms we need the farm information. This resides in the FarmManager held by the landscape, so first we need a pointer to that. The Farm Manager has handy routines for use with the farm allocations .
We need to be able to do the following:
Rule set 0 is simply random distribution to any farm
Rule set 1 - the closest farm
Rule set 2 - Random with openness above cfg_GooseMinForageOpenness
Rule set 3 - random subject to hunter density restrictions
Rule set 4 - openness above cfg_GooseMinForageOpenness but closest to home
Rule set 5 - Pick the closest farm but upto a max hunter density
Rule set 6 - Pick a random farm with openness above and upto a maximum density of hunters
Rule set 7 - Pick the closest farm with openness above and upto a maximum density of hunters
Rule set 8 - the closest farm but based on probability. Requires a probability function which is a power curve using one parameter.
Rule set 9 - the closest farm with openness above X, but based on probability for closeness. Requires a probability function which is a power curve using one parameter.
Rule set 10 - the closest farm with openness above X, on probability for closeness and on density. Requires a probability function which is a power curve using one parameter.
Rule set 11 - the closest farm with openness above X, on probability for closeness and on a probability of the acceptance being reduced with farm size. Requires a probability function which is a power curve using one parameter for distance and a second for area.
Rule set 12 - the closest farm with openness above X, on probability for closeness and on a probability of the acceptance being reduced with distance from roost. Requires a probability function which is a power curve using one parameter for distance and a second for roost distance.
References FarmManager::CalcCentroids(), cfg_goose_MinForageOpenness, cfg_Hunters_Distribute_Ruleset, cfg_Hunters_MaxDensity, CheckDensity(), FarmManager::FindClosestFarm(), FarmManager::FindClosestFarmOpenness(), FarmManager::FindClosestFarmOpennessProb(), FarmManager::FindFarmWithOpenness(), FarmManager::FindFarmWithRandom(), FarmManager::FindOpennessFarm(), g_msg, FarmManager::GetFarmTotalSize(), FarmManager::GetNoFarms(), FarmManager::GetRandomFarmRefnum(), FarmManager::IsDuplicateRef(), Population_Manager::m_TheLandscape, APoint::m_x, APoint::m_y, RuleSet10Based(), Landscape::SupplyFarmManagerPtr(), Landscape::SupplyNumberOfFarms(), CfgInt::value(), CfgFloat::value(), and MapErrorMsg::Warn().
Referenced by DistributeHunters().
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
protectedvirtual |
Does general daily tasks e.g. reset time of day, reset bag lists if start of year etc..
Reimplemented from Population_Manager.
References g_msg, Hunter::GetClock(), Hunter::GetHuntField(), GooseHunter::IsLeader(), Hunter::IsOutHunting(), Hunter::IsSeasonEnd(), m_ActiveHuntingLocationsHunters, m_ActiveHuntingLocationsPolyrefs, m_daytime, Population_Manager::m_ListNameLength, Population_Manager::m_SeasonNumber, Population_Manager::m_TheLandscape, Hunter::OnMorning(), Hunter::ResetClock(), Hunter::ResetSeasonData(), Hunter::SaveMyData(), Landscape::SupplyDayInYear(), Landscape::SupplyYearNumber(), Population_Manager::TheArray, and MapErrorMsg::Warn().
|
inlineprotectedvirtual |
APoint Hunter_Population_Manager::GetHunterHome | ( | int | a_index, |
int | a_list | ||
) |
Returns the hunter home location.
References Population_Manager::TheArray.
APoint Hunter_Population_Manager::GetHunterHuntLoc | ( | int | a_index, |
int | a_list, | ||
unsigned | a_ref | ||
) |
Returns the hunter hunting location location.
References Population_Manager::TheArray.
|
inline |
Get the end of the overall hunting season.
References m_HuntingSeasonEnd.
Referenced by GooseHunter::GetSeasonLengthLeft(), GooseHunter::InSeason(), and GooseHunter::IsSeasonEnd().
|
inline |
Get the start of the overall hunting season.
References m_HuntingSeasonStart.
Referenced by GooseHunter::GetSeasonLengthLeft(), and GooseHunter::InSeason().
unsigned Hunter_Population_Manager::GetNoHuntLocs | ( | ) |
Calculates the number of hunting locations based on a distribution.
Calculates the number of hunting locations based on a distribution. Uses probability of one location, two locations or three+
References cfg_hunterlocFOUR, cfg_hunterlocONE, cfg_hunterlocTHREE, cfg_hunterlocTWO, g_rand_uni, and CfgFloat::value().
Referenced by DistributeHunters().
void Hunter_Population_Manager::HunterLeaderMessage | ( | TypeOfHunterLeaderMessage | a_signal, |
int | a_polyref | ||
) |
A message system to rely messages from the leader hunter to others in his team.
This is used to relay a message from a leader hunter to any other hunters in a field at the same time as the leader. The leader passes the polygon reference number which is used to find the list of hunters. They are then each called passing them an event specified by a_signal (currently there is only two types of message, but this can be expanded).
References g_msg, hlm_gohome, hlm_shoot, m_ActiveHuntingLocationsHunters, m_ActiveHuntingLocationsPolyrefs, and MapErrorMsg::Warn().
Referenced by GooseHunter::st_OutHunting().
void Hunter_Population_Manager::Init | ( | void | ) |
Create the initial hunter population and initializes any output options.
Here we need to create the initial hunter population with each individual with its own hunting pattern in terms of timing, location, and intensity/efficiency. Information on hunters is specified in the Hunter_Hunting_Locations.txt file.
One of the challenges is to ensure that we have a matching prey population for each hunter. This is achieved by two structures, the first being a variable in each Population_Manager that states its type (m_population_type) and its associated enum TTypesOfPopulation. The second is a globally visible structure holding a list of any active population managers.
This method also initializes any output options.
References cfg_Hunters_RecordBag, CreateObjects(), g_msg, g_PopulationManagerList, FarmManager::GetFarmCentroid(), FarmManager::GetFarmPtr(), PopulationManagerList::GetPopulation(), m_daytime, struct_Hunter::m_efficiency, struct_Hunter::m_farms, struct_Hunter::m_goosecountchance, struct_Hunter::m_home, struct_Hunter::m_HType, m_HuntingBagRecord, struct_Hunter::m_huntingdayslimit, struct_Hunter::m_huntlocrefs, struct_Hunter::m_huntlocs, struct_Hunter::m_L, struct_Hunter::m_preyPM, struct_Hunter::m_ref, Population_Manager::m_TheLandscape, struct_Hunter::m_weekend, APoint::m_x, APoint::m_y, Landscape::SupplyFarmManagerPtr(), toh_GooseHunter, TOP_Goose, CfgBool::value(), MapErrorMsg::Warn(), and Landscape::Warn().
Referenced by Hunter_Population_Manager().
bool Hunter_Population_Manager::IsPolyrefOnActiveList | ( | int | a_polyref | ) |
void Hunter_Population_Manager::RecordHuntingSuccess | ( | int | poly, |
int | birds, | ||
int | a_hunter | ||
) |
Hunting bag output.
This method stores information about the birds that have been shot. It is essential that the hunting bag record file is open when this is called - there is no checking. This is controlled by a configuration variable cfg_Hunters_RecordBag
References g_date, Calendar::GetHour(), Calendar::GetMinute(), Population_Manager::GetSeasonNumber(), Population_Manager::m_TheLandscape, APoint::m_x, APoint::m_y, Landscape::SupplyCentroid(), Landscape::SupplyDayInYear(), and Landscape::SupplyYear().
Referenced by GooseHunter::OnShotABird().
void Hunter_Population_Manager::RuleSet10Based | ( | int | a_no_hunters, |
vector< int > * | a_farmsizes, | ||
vector< HunterInfo > * | a_hunterlist, | ||
vector< APoint > * | a_roostlocs, | ||
int | a_ruleset | ||
) |
Used to implement rule sets based on rule set 10.
References cfg_goose_MinForageOpenness, cfg_Hunters_Distribute_Ruleset, CheckDensity(), FarmManager::FindClosestFarmOpennessProb(), FarmManager::FindClosestFarmOpennessProbNearRoostIsBest(), FarmManager::FindClosestFarmOpennessProbSmallIsBest(), g_msg, FarmManager::GetNoFarms(), Population_Manager::m_TheLandscape, Landscape::SupplyFarmManagerPtr(), CfgInt::value(), CfgFloat::value(), and MapErrorMsg::Warn().
Referenced by DistributeHuntersByRules().
void Hunter_Population_Manager::SaveDistributedHunters | ( | vector< HunterInfo > * | a_hunterlist, |
int | a_no_hunters | ||
) |
Saves the results of the hunter distribution to an output file.
Referenced by DistributeHunters().
void Hunter_Population_Manager::SaveFarmHunters | ( | vector< HunterInfo > * | a_hunterlist, |
int | a_no_hunters | ||
) |
Saves the results of the hunter distribution to an output file by farm.
References cfg_goose_MinForageOpenness, FarmManager::GetFarmArableSize(), FarmManager::GetFarmAreaOpenFields(), FarmManager::GetFarmCentroid(), FarmManager::GetFarmNoFields(), FarmManager::GetFarmNoOpenFields(), Farm::GetFarmNumber(), FarmManager::GetFarmPtrIndex(), FarmManager::GetFarmTotalSize(), FarmManager::GetFarmType(), FarmManager::GetFarmValidCoords(), FarmManager::GetNoFarms(), farminfo::m_areaopenfields, farminfo::m_farmarable, farminfo::m_farmcentroid, farminfo::m_farmref, farminfo::m_farmsize, farminfo::m_farmtype, farminfo::m_farmvalid, farminfo::m_nofields, farminfo::m_NoHunters, farminfo::m_openfields, Population_Manager::m_TheLandscape, APoint::m_x, APoint::m_y, Landscape::SupplyFarmManagerPtr(), and CfgFloat::value().
Referenced by DistributeHunters().
void Hunter_Population_Manager::SetHuntingSeason | ( | ) |
This returns the number of geese which are legal quarry on the polygon the day before.
The goose hunting season is complicated because it runs over a year boundary (or it can)
References cfg_goose_greylagopenseasonend, cfg_goose_greylagopenseasonstart, cfg_goose_pinkfootopenseasonend, cfg_goose_pinkfootopenseasonstart, g_msg, m_HuntingSeasonEnd, m_HuntingSeasonStart, CfgInt::value(), and MapErrorMsg::Warn().
Referenced by Hunter_Population_Manager().
|
inlineprotectedvirtual |
Overrides the population manager StepFinished - there is no chance that hunters do not finish a step behaviour.
Returns true if and only if all objects have finished the current step
Reimplemented from Population_Manager.
vector<HunterList*> Hunter_Population_Manager::m_ActiveHuntingLocationsHunters |
Lists of hunters at all active hunting locations (updated daily)
Referenced by AddHunterHunting(), DoFirst(), and HunterLeaderMessage().
vector<int> Hunter_Population_Manager::m_ActiveHuntingLocationsPolyrefs |
Lists of polygon reference numbers for all active hunting locations (updated daily)
Referenced by AddHunterHunting(), DoFirst(), HunterLeaderMessage(), and IsPolyrefOnActiveList().
|
protected |
|
protected |
Output file for hunting bag record.
Referenced by Init(), and ~Hunter_Population_Manager().
|
protected |
End of the overall hunting season.
Referenced by GetHuntingSeasonEnd(), Hunter_Population_Manager(), and SetHuntingSeason().
|
protected |
Start of the overall hunting season.
Referenced by GetHuntingSeasonStart(), Hunter_Population_Manager(), and SetHuntingSeason().